package com.itheima.hello;

import java.util.Scanner;

public class BmiCacal {
    public static void main(String[] args) {
        double height;
        double weight;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入身高：");
        height = scanner.nextDouble();
        System.out.println("请输入体重：");
        weight = scanner.nextDouble();
        System.out.println("请输入性别：");
        String sex = scanner.next();
        System.out.println("请输入年龄：");
        int age = scanner.nextInt();
        bmiJudge(height, weight);
        System.out.println("bmr = " + bmrJudge(height, weight, sex, age));
    }

    //方法：计算用户的BMI，并判断是否健康，根据用户的个人信息：身高，体重，性别，年龄
    public static void bmiJudge(double height, double weight) {
        double bmi = weight / (height * height);
        System.out.println("bmi = " + bmi);
        if (bmi < 18.5) {
            System.out.println("过轻");
        } else if (bmi < 24) {
            System.out.println("正常");
        } else if (bmi < 28) {
            System.out.println("过重");
        } else if (bmi < 32){
            System.out.println("肥胖");
        }
    }

    //方法：计算用户的BMR，并判断是否健康，根据用户的个人信息：身高，体重，性别，年龄
    public static double bmrJudge(double height, double weight, String sex, int age) {
        double bmr = 0;
        if (sex.equals("男")) {
            bmr = 88.362 + (13.397 * weight) + (4.799 * height) - (5.677 * age);
        } else if (sex.equals("女")) {
            bmr = 447.593 + (9.563 * weight) + (3.098 * height) - (4.330 * age);
        }
        return bmr;
    }
}
